package my.framework.controller;

import my.framework.comm.AjaxResult;
import my.framework.comm.RequestMapping;
import my.framework.entity.Auctionuser;
import my.framework.service.IAuctionuserService;
import my.framework.service.impl.AuctionuserServiceImpl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author:雷淑娥
 * @Date:2024/12/13 19:36
 * version:1.0
 */
@RequestMapping("/auth")
public class LoginServlet {
    IAuctionuserService auctionuserService = new AuctionuserServiceImpl();
    @RequestMapping("/login")
    public AjaxResult login(HttpServletRequest request, HttpServletResponse response) {
        String username = request.getParameter("username");
        String password = request.getParameter("password");

        System.out.println("username:" + username);
        System.out.println("password:" + password);
        Auctionuser auctionuser = auctionuserService.login(username,password);
        AjaxResult ajaxResult = new AjaxResult();
        if (auctionuser != null) {
            ajaxResult.setCode(200);
            ajaxResult.setResult(auctionuser);
        }else {
            ajaxResult.setCode(500);
            ajaxResult.setMsg("账号密码错误!");
        }

        return ajaxResult;
    }

}
